package com.tomtop.core.datasource.config;

import java.util.List;
import java.util.Map;

import org.springframework.boot.context.properties.ConfigurationProperties;

import com.tomtop.core.datasource.core.AbstractDataBase.Mapper;
import com.tomtop.core.datasource.core.AbstractDataBase.Order;

@ConfigurationProperties(prefix = "Spring.datasource")
public class DruidConfig {
	private Map<String, DruidNode> druid;
	private DruidProperties defaultConfig;

	public Map<String, DruidNode> getDruid() {
		return druid;
	}

	public void setDruid(Map<String, DruidNode> druid) {
		this.druid = druid;
	}

	public DruidProperties getDefaultConfig() {
		return defaultConfig;
	}

	public void setDefaultConfig(DruidProperties defaultConfig) {
		this.defaultConfig = defaultConfig;
	}

	public static class DruidNode {
		private String name;
		private boolean primary;
		private String basepackage;
		private String mapperpackage;
		private Order order = Order.BEFORE;
		private Mapper mapper = Mapper.DEFAULT;
		private DruidProperties master;
		private List<DruidProperties> slaves;
		
		public boolean isPrimary() {
			return primary;
		}

		public void setPrimary(boolean primary) {
			this.primary = primary;
		}

		public String getName() {
			return name;
		}

		public void setName(String name) {
			this.name = name;
		}

		public DruidProperties getMaster() {
			return master;
		}

		public void setMaster(DruidProperties master) {
			this.master = master;
		}

		public List<DruidProperties> getSlaves() {
			return slaves;
		}

		public void setSlaves(List<DruidProperties> slaves) {
			this.slaves = slaves;
		}

		public String getBasepackage() {
			return basepackage;
		}

		public void setBasepackage(String basepackage) {
			this.basepackage = basepackage;
		}

		public String getMapperpackage() {
			return mapperpackage;
		}

		public void setMapperpackage(String mapperpackage) {
			this.mapperpackage = mapperpackage;
		}

		public Order getOrder() {
			return order;
		}

		public void setOrder(Order order) {
			this.order = order;
		}

		public Mapper getMapper() {
			return mapper;
		}

		public void setMapper(Mapper mapper) {
			this.mapper = mapper;
		}
	}

}
